import 'package:flutter/material.dart';

/// 登录按钮
class LoginButton extends StatelessWidget {
  final bool _busy;
  final String _title;
  final Function _function;

  LoginButton({
    Key key,
    @required String title,
    @required Function function,
  })  : _busy = false,
        _title = title,
        _function = function,
        super(key: key);

  LoginButton.busy({
    Key key,
  })  : _busy = true,
        _title = '未设置',
        _function = (() {
          debugPrint('未设置');
        }),
        super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.all(16),
      width: double.maxFinite,
      child: RaisedButton(
        onPressed: _busy ? null : _function,
        child: _busy
            ? CircularProgressIndicator()
            : Text(
                _title,
                style: TextStyle(fontSize: 18),
              ),
      ),
    );
  }
}
